package zuo.biao.apijson.parser;

import zuo.biao.apijson.parser.builder.Builder;
import zuo.biao.apijson.parser.builder.SQLBuilder;
import zuo.biao.apijson.parser.provider.SQLProvider;

import static zuo.biao.apijson.parser.builder.BuilderType.*;


public abstract class SQLExplorer {
	private SQLExplorer(){}
	public static final SQLBuilder SQL_BUILDER = new SQLBuilder();
	public static final String getSQL(SQLProvider builder){
		return getSQL(new StringBuilder() , builder);
	}
	public static final  String getSQL(Appendable builder, SQLProvider provider){
		String answer;

		switch (provider.getStatementType()) {
			case DELETE:
				answer = SQL_BUILDER.deleteSQL(builder,provider);
				break;

			case INSERT:
				answer = SQL_BUILDER.insertSQL(builder,provider);
				break;

			case SELECT:
				answer = SQL_BUILDER.selectSQL(builder,provider);
				break;

			case UPDATE:
				answer = SQL_BUILDER.updateSQL(builder,provider);
				break;

			default:
				answer = null;
		}
		return answer;
	}

}
